﻿

@model HPIT_LiuzuPoint.Entity.ViewModel.ReceptionEditViewModel



@using (Html.BeginForm("Edit", "reception", FormMethod.Post, new { id = "from_user" }))
{

    <fieldset>
        <legend>会员基本信息</legend> 
        <table align="center">
            <tr>
                <td>姓名：</td>
                <td>@Html.EditorFor(model => model.Name)</td>
                <td>房间价格：</td>
                <td>@Html.EditorFor(model => model.Roomprice)</td>
            </tr>
            <tr>
                <td>酒水：</td>
                <td>@Html.EditorFor(model => model.Drinks)</td>
                <td>消费：</td>
                <td>@Html.EditorFor(model => model.Consume)</td>
            </tr>
            <tr>
                <td>房间类型：</td>
                <td>
                    @Html.DropDownListFor(model => model.RoomId, ViewBag.Ulist as IEnumerable<SelectListItem>)
                </td>
            </tr>

            <tr>
                <td></td>
                <td></td>
                <td><input type="button" id="btn_Submit" value="提交" /></td>
                <td> </td>
            </tr>
        </table>

        @Html.HiddenFor(model => model.Id)
    </fieldset>

}
<script>
    $("#btn_Submit").click(function () {

        var postUrl = "";
        //根据隐藏域的id值来判断是添加还是编辑
        if (parseInt($("#Id").val())>0) {
            postUrl = "/reception/Edit";
        } else {
            postUrl = "/reception/Add";
        }

        $('#from_user').form('submit', {
            url: postUrl,
            onSubmit: function () {
                //var isValid = $(this).form('validate');
                //return isValid;
            },
            success: function (data) {
                //这里data是一个字符串！！不是json对象
                //需要把字符串转换成json对象（反序列化）
                var json = JSON.parse(data);
                console.log(json);
                if (json.State == 1) {
                    //1.提示消息
                    window.parent.$.messager.alert('温馨提示', json.Message,'info')
                    //2.关闭弹窗
                    window.parent.$("#dal").dialog("close");
                    //3.刷新列表
                    window.parent.$('#Us_room').datagrid('reload');

                } else {
                    $.messager.alert('温馨提示', json.Message,'info')
                }
            }
        });
    });
</script>




